package org.dizena.common.interaction.request;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

@ApiModel("分页请求模型")
@Data
public class PageRequest implements Serializable {
    @ApiModelProperty(value = "页码",example = "1")
    private long page = 1;
    @ApiModelProperty(value = "页大小",example = "10")
    private long size = 10;
    @ApiModelProperty(value = "排序字段",example = "id")
    private String sort;
    @ApiModelProperty(value = "排序方向",example = "ASC")
    private String dire;
    @ApiModelProperty(value = "搜索字段",example = "id")
    private String searchField;
    @ApiModelProperty(value = "搜素内容",example = "202112210101")
    private String searchContent;
    @ApiModelProperty(value = "查询条件")
    private List<Condition> conditions;

    public long getSkip() {
        if (this.getPage() < 1) {
            this.page = 1;
        }
        return (this.getPage() - 1) * this.getSize();
    }

    public long getLimit() {
        return this.getSize();
    }


}
